package com.gw2.gw2world.web.server.model;

import java.util.ArrayList;
import java.util.List;

public class Match {
	public enum World {RED, BLUE, GREEN};
	private String match_id, st, et; //start time, end time
	private int red_world_id, blue_world_id, green_world_id;
	private int[] score=new int[]{0,0,0};
	private List<MatchDetail> details;
	public Match() {
		details=new ArrayList<Match.MatchDetail>(4);
	}
	public String getMatch_id() {return match_id;}
	public void setMatch_id(String match_id) {this.match_id = match_id;}
	public String getSt() {return st;}
	public void setStartTime(String st) {this.st = st;}
	public String getEndTime() {return et;}
	public void setEt(String et) {this.et = et;}
	public int getRed_world_id() {return red_world_id;}
	public void setRed_world_id(int red_world_id) {this.red_world_id = red_world_id;}
	public int getBlue_world_id() {return blue_world_id;}
	public void setBlue_world_id(int blue_world_id) {this.blue_world_id = blue_world_id;}
	public int getGreen_world_id() {return green_world_id;}
	public void setGreen_world_id(int green_world_id) {this.green_world_id = green_world_id;}
	public int getScore(World w) {
		if(w==World.RED) return score[0];
		else if(w==World.BLUE) return score[1];
		else if(w==World.GREEN) return score[2];
		else return -1;
	}
	public void setScore(int r, int b, int g) {
		score[0]=r;
		score[1]=b;
		score[2]=g;
	}
	public class Objective {
		private int id;
		private String owner;
		private String owner_guild;
		private Guild owner_detail;
		public Guild getOwner_detail() {return owner_detail;}
		public void setOwner_detail(Guild owner_detail) {this.owner_detail = owner_detail;}
		public int getId() {return id;}
		public void setId(int id) {this.id = id;}
		public String getOwner() {return owner;}
		public void setOwner(String owner) {this.owner = owner;}
		public String getOwner_guild() {return owner_guild;}
		public void setOwner_guild(String owner_guild) {this.owner_guild = owner_guild;}	
	}
	public class MatchDetail {
		private String type;
		private int[] score=new int[]{0,0,0};
		private List<Objective> objectives;
		public MatchDetail() {
			objectives=new ArrayList<Objective>();
		}
		public String getType() {return type;}
		public void setType(String type) {this.type = type;}
		public List<Objective> getObjectives() {return objectives;}
		public int getScore(World w) {
			if(w==World.RED) return this.score[0];
			else if(w==World.BLUE) return this.score[1];
			else if(w==World.GREEN) return this.score[2];
			else return -1;
		}
		public void setScore(int r, int b, int g) {
			this.score[0]=r;
			this.score[1]=b;
			this.score[2]=g;
		}
		public int getCurrentScore(World w) {
			int n=0, i=0;
			if(i==0);
			for(MatchDetail md : details)
				for(Objective o : md.getObjectives()) {
					///TO DO: map of integer, Objective.id and score point (5 camps, 10 towers, 25 keeps, 35 Stonemist Castle)
					if(w==World.RED && o.owner.equals("Red")) ;
					else if(w==World.BLUE && o.owner.equals("Blue")) ;
					else if(w==World.GREEN && o.owner.equals("Green")) ;
				}
			return n;
		}
	}
}
